using System;
using System.ComponentModel;
using System.Globalization;

namespace PeDALS.Tools.AZ.PSTArchive
{
    /// <summary>
    /// The event arguments for iPlug Progress Events
    /// </summary>
    public class ProgressEventArgs : ProgressChangedEventArgs
    {
        #region Private Fields

        private readonly int mintCurrentItemProgress;
        private readonly int mintCurrentTaskProgress;
        private readonly int mintCurrentItemCompletedCount;
        private readonly int mintCurrentTaskCompletedCount;
        private readonly LogEntryType mletType;
        private readonly string mstrStatus;

        #endregion Private Fields

        #region Constructors

        /// <summary>
        /// Creates an new instance of the ProgressEventArgs
        /// </summary>
        /// <param name="intCurrentItemProgress">An integer indicating the current item progress completion percentage within the current task</param>
        /// <param name="intCurrentTaskProgress">An integer indicating the current task progress completion percentage</param>
        /// <param name="intCurrentItemCompletedCount">An integer indicating the current total items completed</param>
        /// <param name="intCurrentTaskCompletedCount">An integer indicating the current total tasks completed</param>
        /// <param name="letType">An enumeration type to indicate to the user interface how to log the individual event</param>
        /// <param name="strStatus">A progress status message to return user interface</param>
        /// <param name="intProgressPercentage">A integer progress completion percentage input.  Inherited from ProgressChangedEventArgs</param>
        /// <param name="oToken">Something something something Dark Side, Something Something Something Something Complete.  Inherited from ProgressChangedEventArgs</param>
        public ProgressEventArgs(int intCurrentItemProgress, int intCurrentTaskProgress, int intCurrentItemCompletedCount, int intCurrentTaskCompletedCount, LogEntryType letType, string strStatus, int intProgressPercentage, object oToken)
            : base(intProgressPercentage, oToken)
        {
            mintCurrentItemProgress = intCurrentItemProgress;
            mintCurrentTaskProgress = intCurrentTaskProgress;
            mintCurrentItemCompletedCount = intCurrentItemCompletedCount;
            mintCurrentTaskCompletedCount = intCurrentTaskCompletedCount;
            mletType = letType;
            mstrStatus = string.Format(CultureInfo.InvariantCulture, "{0}{1}", strStatus.Substring(0, 1).ToUpper(), strStatus.Substring(1, strStatus.Length - 1));
        }

        #endregion Constructors

        #region Public Properties

        public int CurrentItemProgress
        {
            get { return mintCurrentItemProgress; }
        }
	
        public int CurrentTaskProgress
        {
            get { return mintCurrentTaskProgress; }
        }

        public int CurrentItemCompletedCount
        {
            get { return mintCurrentItemCompletedCount; }
        }
	
        public int CurrentTaskCompletedCount
        {
            get { return mintCurrentTaskCompletedCount; }
        }

        public LogEntryType EntryType
        {
            get { return mletType; }
        }
	
        public string Status
        {
            get { return mstrStatus; }
        }

        #endregion Public Properties
    }

    /// <summary>
    /// The event arguments for iPlug Complete Events
    /// </summary>
    public class CompleteEventArgs : AsyncCompletedEventArgs
    {
        #region Private Fields

        private readonly int mintItemCount;
        private readonly int mintTaskCount;
        private readonly LogEntryType mletType;
        private readonly string mstrStatus;
        private readonly TimeSpan mtsElapsedTime;

        #endregion Private Fields

        #region Constructors

        /// <summary>
        /// Creates an new instance of the ProgressEventArgs
        /// </summary>
        /// <param name="intItemCount">An integer indicating the count of items completed</param>
        /// <param name="intTaskCount">An integer indicating the count of tasks completed</param>
        /// <param name="letType">An enumeration type to indicate to the user interface how to log the individual event</param>
        /// <param name="strStatus">A progress status message to return user interface</param>
        /// <param name="tsElapsedTime">Something something something Dark Side, Something Something Something Something Complete</param>
        /// <param name="eException">Something something something Dark Side, Something Something Something Something Complete.  Inherited from AsyncCompletedEventArgs</param>
        /// <param name="blnCancelled">Something something something Dark Side, Something Something Something Something Complete.  Inherited from AsyncCompletedEventArgs</param>
        /// <param name="oToken">Something something something Dark Side, Something Something Something Something Complete.  Inherited from AsyncCompletedEventArgs</param>
        public CompleteEventArgs(int intItemCount, int intTaskCount, LogEntryType letType, string strStatus, TimeSpan tsElapsedTime, System.Exception eException, bool blnCancelled, object oToken)
            : base(eException, blnCancelled, oToken)
        {
            mintItemCount = intItemCount;
            mintTaskCount = intTaskCount;
            mletType = letType;
            mstrStatus = string.Format(CultureInfo.InvariantCulture, "{0}{1}", strStatus.Substring(0, 1).ToUpper(), strStatus.Substring(1, strStatus.Length - 1));
            mtsElapsedTime = tsElapsedTime;
        }

        #endregion Constructors

        #region Public Properties

        public int ItemCount
        {
            get { RaiseExceptionIfNecessary(); return mintItemCount; }
        }
	
        public int TaskCount
        {
            get { RaiseExceptionIfNecessary(); return mintTaskCount; }
        }

        public LogEntryType EntryType
        {
            get { return mletType; }
        }
		
        public string Status
        {
            get { RaiseExceptionIfNecessary(); return mstrStatus; }
        }
	
        public TimeSpan ElapsedTime
        {
            get { RaiseExceptionIfNecessary(); return mtsElapsedTime; }
        }

        #endregion Public Properties
    }
}